package jupitermouse.site.example.scala.window

import java.util.Properties

import org.apache.flink.api.common.serialization.SimpleStringSchema
import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer

object LogAnalysis {
  def main(args: Array[String]): Unit = {

    val env = StreamExecutionEnvironment.getExecutionEnvironment;

    //接受Kafka数据
    val topic = "flink"

    val properties = new Properties();
    properties.setProperty("bootstrap.servers", "192.168.81.130:9092")
    properties.setProperty("zookeeper.connect", "192.168.81.130:2181")
    properties.setProperty("group.id","test-flink")
    val consumer = new FlinkKafkaConsumer[String](topic, new SimpleStringSchema(),properties)

    import org.apache.flink.api.scala._

    val data = env.addSource(consumer)

    data.print().setParallelism(1)

    env.execute("LogAnalysis")

  }
}
